package com.asia5b.a5mall.middleware.logic.viewmodel.home

import androidx.lifecycle.MutableLiveData
import com.asia5b.a5mall.middleware.base.SimpleNetParams
import com.asia5b.a5mall.middleware.base.SimpleViewModel
import com.asia5b.a5mall.middleware.model.home.CategoryModel
import io.reactivex.functions.Consumer

/**
 * Created by zhangyuncai on 2019/12/21.
 * @Note   分类Fragment逻辑控制器
 */
class CategoryFragmentVM :SimpleViewModel() {

    val loadLeftDatasLiveData=MutableLiveData<ArrayList<CategoryModel>>()
    /**
     * @Note   加载分类数据
     */
    fun loadLeftDatas(refresh:Int) {
        val observable = categoryApi.getParentCat()
        baseSubscribe(observable, SimpleNetParams(isShowLoading = refresh!=1), Consumer { result ->
            loadLeftDatasLiveData.value=result
        }, Consumer<Throwable> {
            loadLeftDatasLiveData.value=arrayListOf()
        })
    }

    /**
     * @Note   加载子分类
     * @param  parentId 父分类ID
     */
    fun loaRightDatas(parentId: Int) {
//        val observable = categoryApi.getChildCat(parentId)
//        baseSubscribe(observable, NetParams(), Consumer { result ->
//            providerView().loadRightDatasResult(result)
//        }, Consumer<Throwable> {
//            providerView().loadRightDatasResult(arrayListOf())
//        })
    }


}